//logs.js
var app = getApp();
import Api from '../../../api/api.js';
const api = new Api();
Page({
  data: {
    dataList: [],
    selectedIndex:-1,
  },
  onLoad: function () {
   this.getListData();
  },
  selecteClick(e){
    var index = parseInt(e.currentTarget.dataset.key);
    this.setData({
      selectedIndex:index
    });
    // var dict = this.data.dataList[index];
    // if (dict.isSelected == "0"){
    //   dict.isSelected = "1";
    // } else {
    //   dict.isSelected = "0";
    // }
    // this.setData({
    //   dataList:this.data.dataList
    // });
  },
  getListData() {
    var _this = this;
    var map = {};
    api.getRequestData(app.zhongCaoGoodsUrl, map, true, "POST").then(res => {
      if (res.data.errorCode == 0) {
        var list = res.data.model;
        console.log(JSON.stringify(list[0]));
        // for (var i = 0;i < list.length;i++){
        //   var dict = list[i];
        //   dict.isSelected = "0";
        // }
        _this.data.dataList = list;
        _this.setData({
          dataList: _this.data.dataList
        });
      } else {
        wx.showToast({
          title: res.data.errorMsg,
          icon: 'none',
          duration: 1500
        });
      }
    });
  },
  zhongCaoClick(){
    var dict = this.data.dataList[this.data.selectedIndex];
    var zhongCaoString = JSON.stringify(dict);
    wx.setStorageSync('zcList', zhongCaoString);
    wx.removeStorageSync('bfList')

    wx.navigateBack({});
  },
  
})
